package aybolit.core.objects.model;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Vadim
 * Date: 13.03.13
 * Time: 16:57
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class Patientes implements Serializable {
    private int patientId;

    @Column(name = "patient_id")
    @Id
    public int getPatientId() {
        return patientId;
    }

    public void setPatientId(int patientId) {
        this.patientId = patientId;
    }

    private String name;

    @Column(name = "name")
    @Basic
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    private String midName;

    @Column(name = "mid_name")
    @Basic
    public String getMidName() {
        return midName;
    }

    public void setMidName(String midName) {
        this.midName = midName;
    }

    private String lastName;

    @Column(name = "last_name")
    @Basic
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    private String passport;

    @Column(name = "passport")
    @Basic
    public String getPassport() {
        return passport;
    }

    public void setPassport(String passport) {
        this.passport = passport;
    }

    private String address;

    @Column(name = "address")
    @Basic
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    private Date birthday;

    @Column(name = "birthday")
    @Basic
    @Temporal(javax.persistence.TemporalType.DATE)
    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    private String workplace;

    @Column(name = "workplace")
    @Basic
    public String getWorkplace() {
        return workplace;
    }

    public void setWorkplace(String workplace) {
        this.workplace = workplace;
    }

    private String profession;

    @Column(name = "profession")
    @Basic
    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    private int male;

    @Column(name = "male")
    @Basic
    public int getMale() {
        return male;
    }

    public void setMale(int male) {
        this.male = male;
    }

    private int familyStatus;

    @Column(name = "family_status")
    @Basic
    public int getFamilyStatus() {
        return familyStatus;
    }

    public void setFamilyStatus(int familyStatus) {
        this.familyStatus = familyStatus;
    }

    private Timestamp timestamp;

    @Column(name = "timestamp_")
    @Basic
    public Timestamp getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Timestamp timestamp) {
        this.timestamp = timestamp;
    }

    private int hospitalId;

    @Column(name = "hospital_id")
    @Basic
    public int getHospitalId() {
        return hospitalId;
    }

    public void setHospitalId(int hospitalId) {
        this.hospitalId = hospitalId;
    }

    private int operatorId;

    @Column(name = "operator_id")
    @Basic
    public int getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(int operatorId) {
        this.operatorId = operatorId;
    }

    private int patientStatus;

    @Column(name = "patient_status")
    @Basic
    public int getPatientStatus() {
        return patientStatus;
    }

    public void setPatientStatus(int patientStatus) {
        this.patientStatus = patientStatus;
    }

    private int departmantId;

    @Column(name = "departmant_id")
    @Basic
    public int getDepartmantId() {
        return departmantId;
    }

    public void setDepartmantId(int departmantId) {
        this.departmantId = departmantId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Patientes patientes = (Patientes) o;

        if (departmantId != patientes.departmantId) return false;
        if (familyStatus != patientes.familyStatus) return false;
        if (hospitalId != patientes.hospitalId) return false;
        if (male != patientes.male) return false;
        if (operatorId != patientes.operatorId) return false;
        if (patientId != patientes.patientId) return false;
        if (patientStatus != patientes.patientStatus) return false;
        if (address != null ? !address.equals(patientes.address) : patientes.address != null) return false;
        if (birthday != null ? !birthday.equals(patientes.birthday) : patientes.birthday != null) return false;
        if (lastName != null ? !lastName.equals(patientes.lastName) : patientes.lastName != null) return false;
        if (midName != null ? !midName.equals(patientes.midName) : patientes.midName != null) return false;
        if (name != null ? !name.equals(patientes.name) : patientes.name != null) return false;
        if (passport != null ? !passport.equals(patientes.passport) : patientes.passport != null) return false;
        if (profession != null ? !profession.equals(patientes.profession) : patientes.profession != null) return false;
        if (timestamp != null ? !timestamp.equals(patientes.timestamp) : patientes.timestamp != null) return false;
        if (workplace != null ? !workplace.equals(patientes.workplace) : patientes.workplace != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = patientId;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (midName != null ? midName.hashCode() : 0);
        result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
        result = 31 * result + (passport != null ? passport.hashCode() : 0);
        result = 31 * result + (address != null ? address.hashCode() : 0);
        result = 31 * result + (birthday != null ? birthday.hashCode() : 0);
        result = 31 * result + (workplace != null ? workplace.hashCode() : 0);
        result = 31 * result + (profession != null ? profession.hashCode() : 0);
        result = 31 * result + male;
        result = 31 * result + familyStatus;
        result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
        result = 31 * result + hospitalId;
        result = 31 * result + operatorId;
        result = 31 * result + patientStatus;
        result = 31 * result + departmantId;
        return result;
    }

    private Collection<Beds> bedsesByPatientId;

    @OneToMany(mappedBy = "patientesByPatientId")
    public Collection<Beds> getBedsesByPatientId() {
        return bedsesByPatientId;
    }

    public void setBedsesByPatientId(Collection<Beds> bedsesByPatientId) {
        this.bedsesByPatientId = bedsesByPatientId;
    }

    private Departments departmentsByDepartmantId;

    @ManyToOne
    public
    @JoinColumn(name = "departmant_id", referencedColumnName = "department_id", table = "patientes")
    Departments getDepartmentsByDepartmantId() {
        return departmentsByDepartmantId;
    }

    public void setDepartmentsByDepartmantId(Departments departmentsByDepartmantId) {
        this.departmentsByDepartmantId = departmentsByDepartmantId;
    }

    private Hospitales hospitalesByHospitalId;

    @ManyToOne
    public
    @JoinColumn(name = "hospital_id", referencedColumnName = "hospital_id", table = "patientes")
    Hospitales getHospitalesByHospitalId() {
        return hospitalesByHospitalId;
    }

    public void setHospitalesByHospitalId(Hospitales hospitalesByHospitalId) {
        this.hospitalesByHospitalId = hospitalesByHospitalId;
    }

    private Operators operatorsByOperatorId;

    @ManyToOne
    public
    @JoinColumn(name = "operator_id", referencedColumnName = "oper_id", table = "patientes")
    Operators getOperatorsByOperatorId() {
        return operatorsByOperatorId;
    }

    public void setOperatorsByOperatorId(Operators operatorsByOperatorId) {
        this.operatorsByOperatorId = operatorsByOperatorId;
    }

    private PatientStatuses patientStatusesByPatientStatus;

    @ManyToOne
    public
    @JoinColumn(name = "patient_status", referencedColumnName = "patient_status_id", table = "patientes")
    PatientStatuses getPatientStatusesByPatientStatus() {
        return patientStatusesByPatientStatus;
    }

    public void setPatientStatusesByPatientStatus(PatientStatuses patientStatusesByPatientStatus) {
        this.patientStatusesByPatientStatus = patientStatusesByPatientStatus;
    }

    private Collection<Healing> healingsByPatientId;

    @OneToMany(mappedBy = "patientesByPatientId")
    public Collection<Healing> getHealingsByPatientId() {
        return healingsByPatientId;
    }

    public void setHealingsByPatientId(Collection<Healing> healingsByPatientId) {
        this.healingsByPatientId = healingsByPatientId;
    }

    private Collection<HealingDoctors> healingDoctorsesByPatientId;

    @OneToMany(mappedBy = "patientesByPatientId")
    public Collection<HealingDoctors> getHealingDoctorsesByPatientId() {
        return healingDoctorsesByPatientId;
    }

    public void setHealingDoctorsesByPatientId(Collection<HealingDoctors> healingDoctorsesByPatientId) {
        this.healingDoctorsesByPatientId = healingDoctorsesByPatientId;
    }
}
